{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Fight_Detection_NoteBook_Final.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "machine_shape": "hm"
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU",
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "f0a6cad2707f4799a9acad533af921b6": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "model_module_version": "1.5.0",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_828e9fae284a455a8f67d49e1a1ee9d1",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_7558ee4ed88b4f18b9d689b7dca44714",
              "IPY_MODEL_bbd4cd4b8b974e999f3691042aebf34e",
              "IPY_MODEL_a6cbcf5028f8422d916d4c82497a1dbd"
            ]
          }
        },
        "828e9fae284a455a8f67d49e1a1ee9d1": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "7558ee4ed88b4f18b9d689b7dca44714": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_c0ee7e7403154a42b4af1801288dd478",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": "100%",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_509db9a067dd4762a899a2f9ce1fde45"
          }
        },
        "bbd4cd4b8b974e999f3691042aebf34e": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "model_module_version": "1.5.0",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_cb17fa7b7f5f41839c343101e81781a0",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 126162996,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 126162996,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_75fe7d9015894182a3a1454658c8e50e"
          }
        },
        "a6cbcf5028f8422d916d4c82497a1dbd": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "model_module_version": "1.5.0",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_d8eb67971aaf4a5cb5aa2205240a460f",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 120M/120M [00:01&lt;00:00, 94.9MB/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_f3db09b7873345b2b5351db09d0548ed"
          }
        },
        "c0ee7e7403154a42b4af1801288dd478": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "509db9a067dd4762a899a2f9ce1fde45": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "cb17fa7b7f5f41839c343101e81781a0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "75fe7d9015894182a3a1454658c8e50e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "d8eb67971aaf4a5cb5aa2205240a460f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "model_module_version": "1.5.0",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "f3db09b7873345b2b5351db09d0548ed": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "model_module_version": "1.2.0",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        }
      }
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Fight_Detection_From_Surveillance_Cameras-PyTorch_Project"
      ],
      "metadata": {
        "id": "dPnzNjcNrHcg"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from google.colab import drive\n",
        "drive._mount('/content/drive')"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "xlnGodyIcy_N",
        "outputId": "d871d964-1286-47ee-801d-b57b556970cd"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /content/drive\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Load the Project Repo from Github\n",
        "%%capture\n",
        "! git clone https://github.com/MohamedSebaie/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project"
      ],
      "metadata": {
        "id": "-WfNRiAwrIDF"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Discard the output of this cell.\n",
        "%%capture\n",
        "# Install the required libraries.\n",
        "!pip install pafy youtube-dl moviepy\n",
        "!pip install pytube"
      ],
      "metadata": {
        "id": "5rT3ZO-1FDut"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "%%capture\n",
        "import random\n",
        "import time\n",
        "import math\n",
        "import numpy as np\n",
        "import torch\n",
        "import os\n",
        "import cv2\n",
        "import torchvision\n",
        "from moviepy.editor import *\n",
        "from collections import deque"
      ],
      "metadata": {
        "id": "cUE1iu_RrXyn"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\n",
        "device"
      ],
      "metadata": {
        "id": "a6LkxC50gYfM",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "173c741a-fe66-4779-bfd2-284d25aa3930"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "device(type='cuda', index=0)"
            ]
          },
          "metadata": {},
          "execution_count": 5
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "aPgvPwAQi80Y",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "95a95245-43d5-4c47-db31-982a072ca21f"
      },
      "source": [
        "cd /content/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project/UtilsFiles"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "/content/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import Fight_utils\n",
        "from Fight_utils import *"
      ],
      "metadata": {
        "id": "jr0WCuH-MHcR"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "j6MLp9PpDJ4-"
      },
      "source": [
        "DATASET_DIR = '/content/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project/Dataset'\n",
        "CLASSES_LIST = ['fight','noFight']\n",
        "SEQUENCE_LENGTH = 16\n",
        "batch_size= 4"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# FineTuninng and Training"
      ],
      "metadata": {
        "id": "NRD8sXQYdG1E"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "%%capture\n",
        "seed_constant = 70\n",
        "np.random.seed(seed_constant)\n",
        "random.seed(seed_constant)\n",
        "torch.manual_seed(seed_constant)\n",
        "torch.cuda.manual_seed_all(seed_constant)"
      ],
      "metadata": {
        "id": "er2NqgsfUt3i"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8HL3g6QLfS7M",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 66,
          "referenced_widgets": [
            "f0a6cad2707f4799a9acad533af921b6",
            "828e9fae284a455a8f67d49e1a1ee9d1",
            "7558ee4ed88b4f18b9d689b7dca44714",
            "bbd4cd4b8b974e999f3691042aebf34e",
            "a6cbcf5028f8422d916d4c82497a1dbd",
            "c0ee7e7403154a42b4af1801288dd478",
            "509db9a067dd4762a899a2f9ce1fde45",
            "cb17fa7b7f5f41839c343101e81781a0",
            "75fe7d9015894182a3a1454658c8e50e",
            "d8eb67971aaf4a5cb5aa2205240a460f",
            "f3db09b7873345b2b5351db09d0548ed"
          ]
        },
        "outputId": "ccc4ca8d-db79-4e5f-dc5b-fb42fd5db985"
      },
      "source": [
        "model_ft = torchvision.models.video.r2plus1d_18(pretrained=True, progress=True)"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "Downloading: \"https://download.pytorch.org/models/r2plus1d_18-91a641e6.pth\" to /root/.cache/torch/hub/checkpoints/r2plus1d_18-91a641e6.pth\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "f0a6cad2707f4799a9acad533af921b6",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "  0%|          | 0.00/120M [00:00<?, ?B/s]"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "num_ftrs = model_ft.fc.in_features   #in_features\n",
        "model_ft.fc = torch.nn.Linear(num_ftrs, 2) #nn.Linear(in_features, out_features)"
      ],
      "metadata": {
        "id": "YX7KgrBMkMAj"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "x_tensor, y_tensor=Fight_utils.create_dataset(DATASET_DIR,CLASSES_LIST,SEQUENCE_LENGTH)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "VdXspQhNpqZF",
        "outputId": "3122edcb-8f60-45dd-b1e8-734243511bcc"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Extracting Data of Class: fight\n",
            "Extracting Data of Class: noFight\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "x_tensor.shape"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "RnoDxGdjXwAH",
        "outputId": "cffd6b9e-0ab0-4865-f2db-151f8cf14f54"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "torch.Size([300, 3, 16, 112, 112])"
            ]
          },
          "metadata": {},
          "execution_count": 13
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "x_tensor, y_tensor = x_tensor.to(device), y_tensor.to(device)"
      ],
      "metadata": {
        "id": "nDpTRpKo7U6n"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "dataset = torch.utils.data.TensorDataset(x_tensor, y_tensor)\n",
        "val_size = int(len(dataset)*0.3)\n",
        "train_size = len(dataset)- int(len(dataset)*0.3)\n",
        "train_dataset, test_val_dataset = torch.utils.data.random_split(dataset, [train_size, val_size])"
      ],
      "metadata": {
        "id": "mGmuB9X8pmAf"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "val_size = int(len(test_val_dataset)*0.5)\n",
        "test_size = len(test_val_dataset)- int(len(test_val_dataset)*0.5)\n",
        "val_dataset, test_dataset = torch.utils.data.random_split(test_val_dataset, [val_size, test_size])"
      ],
      "metadata": {
        "id": "hvq8VdFomzEg"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "train_loader = torch.utils.data.DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True)\n",
        "val_loader = torch.utils.data.DataLoader(dataset=val_dataset, batch_size=batch_size, shuffle=True)"
      ],
      "metadata": {
        "id": "btK1wCVU6ZsN"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "177Mc-us2TCo"
      },
      "source": [
        "dataloaders_dict = {'train':train_loader,'val':val_loader }"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# To empty the Memory\n",
        "torch.cuda.empty_cache()"
      ],
      "metadata": {
        "id": "UplDJI_18iTO"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "KWFHe9m73HqI"
      },
      "source": [
        "# Send the model to GPU\n",
        "model_ft = model_ft.to(device)\n",
        "\n",
        "# No of Epochs\n",
        "epochs = 30\n",
        "\n",
        "# Loss Function\n",
        "criterion = torch.nn.CrossEntropyLoss()\n",
        "\n",
        "# Optimization Function (SGD-----> Stocastic Gradient Descent)\n",
        "optimizer_ft = torch.optim.SGD(model_ft.parameters(), lr=0.001, momentum=0.9)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Train and evaluate\n",
        "model_ft, hist = Fight_utils.train_model(device,model_ft, dataloaders_dict, criterion, optimizer_ft, num_epochs=epochs)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "G8AW_dw3EsPD",
        "outputId": "38c7b3ec-036b-41f5-9078-928fdd36cdfe"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Epoch 0/29\n",
            "----------\n",
            "train Loss: 0.6863 Acc: 0.6143\n",
            "val Loss: 0.5424 Acc: 0.6444\n",
            "\n",
            "Epoch 1/29\n",
            "----------\n",
            "train Loss: 0.5675 Acc: 0.7190\n",
            "val Loss: 0.3053 Acc: 0.8667\n",
            "\n",
            "Epoch 2/29\n",
            "----------\n",
            "train Loss: 0.3378 Acc: 0.8667\n",
            "val Loss: 0.3344 Acc: 0.8889\n",
            "\n",
            "Epoch 3/29\n",
            "----------\n",
            "train Loss: 0.4324 Acc: 0.8476\n",
            "val Loss: 0.3184 Acc: 0.8667\n",
            "\n",
            "Epoch 4/29\n",
            "----------\n",
            "train Loss: 0.4694 Acc: 0.8238\n",
            "val Loss: 0.3480 Acc: 0.8667\n",
            "\n",
            "Epoch 5/29\n",
            "----------\n",
            "train Loss: 0.2858 Acc: 0.8857\n",
            "val Loss: 0.5155 Acc: 0.8222\n",
            "\n",
            "Epoch 6/29\n",
            "----------\n",
            "train Loss: 0.2248 Acc: 0.9286\n",
            "val Loss: 0.5998 Acc: 0.8000\n",
            "\n",
            "Epoch 7/29\n",
            "----------\n",
            "train Loss: 0.1387 Acc: 0.9476\n",
            "val Loss: 0.3467 Acc: 0.8667\n",
            "\n",
            "Epoch 8/29\n",
            "----------\n",
            "train Loss: 0.3268 Acc: 0.8905\n",
            "val Loss: 0.5603 Acc: 0.8444\n",
            "\n",
            "Epoch 9/29\n",
            "----------\n",
            "train Loss: 0.1951 Acc: 0.9381\n",
            "val Loss: 0.4016 Acc: 0.8889\n",
            "\n",
            "Epoch 10/29\n",
            "----------\n",
            "train Loss: 0.2122 Acc: 0.9000\n",
            "val Loss: 0.4281 Acc: 0.8667\n",
            "\n",
            "Epoch 11/29\n",
            "----------\n",
            "train Loss: 0.2384 Acc: 0.9095\n",
            "val Loss: 0.4159 Acc: 0.8444\n",
            "\n",
            "Epoch 12/29\n",
            "----------\n",
            "train Loss: 0.2348 Acc: 0.9238\n",
            "val Loss: 0.6535 Acc: 0.8444\n",
            "\n",
            "Epoch 13/29\n",
            "----------\n",
            "train Loss: 0.1036 Acc: 0.9524\n",
            "val Loss: 0.5720 Acc: 0.8444\n",
            "\n",
            "Epoch 14/29\n",
            "----------\n",
            "train Loss: 0.3157 Acc: 0.9095\n",
            "val Loss: 0.4441 Acc: 0.8000\n",
            "\n",
            "Epoch 15/29\n",
            "----------\n",
            "train Loss: 0.1786 Acc: 0.9429\n",
            "val Loss: 0.5130 Acc: 0.8667\n",
            "\n",
            "Epoch 16/29\n",
            "----------\n",
            "train Loss: 0.2100 Acc: 0.9190\n",
            "val Loss: 0.3575 Acc: 0.8667\n",
            "\n",
            "Epoch 17/29\n",
            "----------\n",
            "train Loss: 0.1679 Acc: 0.9429\n",
            "val Loss: 0.4090 Acc: 0.8667\n",
            "\n",
            "Epoch 18/29\n",
            "----------\n",
            "train Loss: 0.1439 Acc: 0.9429\n",
            "val Loss: 0.4280 Acc: 0.8444\n",
            "\n",
            "Epoch 19/29\n",
            "----------\n",
            "train Loss: 0.2130 Acc: 0.9238\n",
            "val Loss: 0.5203 Acc: 0.8444\n",
            "\n",
            "Epoch 20/29\n",
            "----------\n",
            "train Loss: 0.1116 Acc: 0.9667\n",
            "val Loss: 0.4135 Acc: 0.8444\n",
            "\n",
            "Epoch 21/29\n",
            "----------\n",
            "train Loss: 0.0606 Acc: 0.9810\n",
            "val Loss: 0.5160 Acc: 0.8222\n",
            "\n",
            "Epoch 22/29\n",
            "----------\n",
            "train Loss: 0.1252 Acc: 0.9667\n",
            "val Loss: 0.4127 Acc: 0.8222\n",
            "\n",
            "Epoch 23/29\n",
            "----------\n",
            "train Loss: 0.0626 Acc: 0.9810\n",
            "val Loss: 0.6551 Acc: 0.8444\n",
            "\n",
            "Epoch 24/29\n",
            "----------\n",
            "train Loss: 0.2403 Acc: 0.9190\n",
            "val Loss: 0.3066 Acc: 0.8889\n",
            "\n",
            "Epoch 25/29\n",
            "----------\n",
            "train Loss: 0.1776 Acc: 0.9286\n",
            "val Loss: 0.3373 Acc: 0.8667\n",
            "\n",
            "Epoch 26/29\n",
            "----------\n",
            "train Loss: 0.1547 Acc: 0.9429\n",
            "val Loss: 0.3015 Acc: 0.8444\n",
            "\n",
            "Epoch 27/29\n",
            "----------\n",
            "train Loss: 0.0759 Acc: 0.9762\n",
            "val Loss: 0.2824 Acc: 0.8667\n",
            "\n",
            "Epoch 28/29\n",
            "----------\n",
            "train Loss: 0.1131 Acc: 0.9476\n",
            "val Loss: 0.5228 Acc: 0.8667\n",
            "\n",
            "Epoch 29/29\n",
            "----------\n",
            "train Loss: 0.1883 Acc: 0.9238\n",
            "val Loss: 0.5376 Acc: 0.8667\n",
            "\n",
            "Training complete in 34m 55s\n",
            "Best val Acc: 0.888889\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "since = time.time()\n",
        "test_loader = torch.utils.data.DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=True)\n",
        "model_ft.eval()\n",
        "running_loss = 0.0\n",
        "running_corrects = 0\n",
        "y_test = []\n",
        "y_pred = []\n",
        "for inputs, labels in test_loader:\n",
        "  inputs = inputs.to(device)\n",
        "  labels = labels.to(device)\n",
        "  optimizer_ft.zero_grad()\n",
        "  with torch.set_grad_enabled(False):\n",
        "    outputs = model_ft(inputs)\n",
        "    loss = criterion(outputs, labels)\n",
        "    _, preds = torch.max(outputs, 1)\n",
        "  running_loss += loss.item() * inputs.size(0)\n",
        "  running_corrects += torch.sum(preds == labels.data)\n",
        "  y_test += labels.data.tolist()\n",
        "  y_pred += preds.data.tolist()\n",
        "\n",
        "epoch_loss = running_loss / len(test_loader.dataset)\n",
        "epoch_acc = running_corrects.double() / len(test_loader.dataset)\n",
        "time_elapsed = time.time() - since\n",
        "print('Training complete in {:.0f}m {:.0f}s'.format(time_elapsed // 60, time_elapsed % 60))\n",
        "print('Loss: {:.4f} Acc: {:.4f}'.format(epoch_loss, epoch_acc))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "bIHThadai1bS",
        "outputId": "f7bf3a4f-0c87-4eec-bc94-775784972e23"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Training complete in 0m 4s\n",
            "Loss: 0.4137 Acc: 0.8222\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.metrics import confusion_matrix\n",
        "#Generate the confusion matrix\n",
        "cf_matrix = confusion_matrix(y_test, y_pred)\n",
        "print(cf_matrix)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "OUk7lYPixUqj",
        "outputId": "52a8f299-d5ab-4d51-b75d-4b54ca6573ff"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[[16  6]\n",
            " [ 2 21]]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns\n",
        "ax = sns.heatmap(cf_matrix, annot=True, cmap='Blues')\n",
        "ax.set_title('Confusion Matrix\\n\\n');\n",
        "ax.set_xlabel('\\nPredicted Values')\n",
        "ax.set_ylabel('Actual Values ');\n",
        "## Ticket labels - List must be in alphabetical order\n",
        "ax.xaxis.set_ticklabels(['fight','noFight'])\n",
        "ax.yaxis.set_ticklabels(['fight','noFight'])\n",
        "## Display the visualization of the Confusion Matrix.\n",
        "plt.show()"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 337
        },
        "id": "NkCen-JYzmL2",
        "outputId": "d0841c4e-8eab-4f50-8e21-79e14df5693b"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAAN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
            "text/plain": [
              "<Figure size 432x288 with 2 Axes>"
            ]
          },
          "metadata": {
            "needs_background": "light"
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Save and Load the Model"
      ],
      "metadata": {
        "id": "mZgiuCabdPAL"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# # To Save the Model\n",
        "# PATH=\"/content/drive/MyDrive/Fight_Detection_Project/First_Run_State70_Seq16_Batch8/model_16_70_8_0.8667.pth\"\n",
        "# torch.save(model_ft.state_dict(), PATH)"
      ],
      "metadata": {
        "id": "G2SShMx4Wgtw"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Later to Load the Saved Model:\n",
        "%%capture\n",
        "PATH=\"/content/drive/MyDrive/Fight_Detection_Project/First_Run_State70_Seq16_Batch4/model_16_70_4_0.88.pth\"\n",
        "model_ft = torchvision.models.video.r2plus1d_18(pretrained=True, progress=True)\n",
        "num_ftrs = model_ft.fc.in_features   #in_features\n",
        "model_ft.fc = torch.nn.Linear(num_ftrs, 2) #nn.Linear(in_features, out_features)\n",
        "model_ft.load_state_dict(torch.load(PATH))\n",
        "model_ft.to(device)\n",
        "model_ft.eval()"
      ],
      "metadata": {
        "id": "Y2jlP1JvWpmt"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Predict"
      ],
      "metadata": {
        "id": "YrDZnx0uLrq3"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "%%capture\n",
        "# Download Videos From Youtube for Testing\n",
        "Fight_utils.downloadYouTube(\"https://www.youtube.com/watch?v=dxOpYEFf9zs&ab_channel=PluggingDaily\", \"/content/\")\n",
        "Fight_utils.downloadYouTube(\"https://www.youtube.com/watch?v=rEiEJT6B7Yo&ab_channel=TelegramVideo\",\"/content/\")\n",
        "\n",
        "# Rename the Videos\n",
        "!mv \"/content/CRAZY FIGHT INSIDE OF CHINESE RESTAURANT 2020.mp4\" \"/content/test1.mp4\"\n",
        "!mv \"/content/Fight outside Dubai Restaurant and Lounge.mp4\" \"/content/test2.mp4\""
      ],
      "metadata": {
        "id": "Kjc5_P2xivy-"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Extract video frames of it (noFight Video)\n",
        "%%capture\n",
        "!y | ffmpeg -ss 00:00:00 -i /content/test1.mp4 -t 00:00:10 -c copy /content/out1.mp4\n",
        "\n",
        "# Extract video frames of it (Fight Video)\n",
        "!y | ffmpeg -ss 00:02:28 -i /content/test1.mp4 -t 00:00:10 -c copy /content/out2.mp4\n",
        "\n",
        "# Extract video frames of it (Fight & noFight Video)\n",
        "!y | ffmpeg -ss 00:01:28 -i /content/test1.mp4 -t 00:02:28 -c copy /content/out3.mp4\n",
        "\n",
        "# Extract video frames of it (Fight & noFight Video)\n",
        "!y | ffmpeg -ss 00:01:10 -i /content/test2.mp4 -t 00:00:50 -c copy /content/out4.mp4"
      ],
      "metadata": {
        "id": "DXMoQbXGlng9"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# output video (noFight Video)\n",
        "path_output = \"/content/out1.mp4\"\n",
        "Fight_utils.show_video(path_output, width=960)"
      ],
      "metadata": {
        "id": "xGj3x_nLl0Or"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# output video (Fight Video)\n",
        "path_output = \"/content/out2.mp4\"\n",
        "Fight_utils.show_video(path_output, width=960)\n"
      ],
      "metadata": {
        "id": "WWOgcNUrhqp2"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# output video (fight & noFight Video)\n",
        "path_output = \"/content/out3.mp4\"\n",
        "Fight_utils.show_video(path_output, width=960)"
      ],
      "metadata": {
        "id": "-51RFzr5IDNC"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# output video (fight & noFight Video)\n",
        "path_output = \"/content/out4.mp4\"\n",
        "Fight_utils.show_video(path_output, width=960)"
      ],
      "metadata": {
        "id": "mDWpGVwiVwoz"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "video_file_path1=\"/content/out1.mp4\"\n",
        "video_file_path2=\"/content/out2.mp4\"\n",
        "video_file_path3=\"/content/out3.mp4\"\n",
        "video_file_path4=\"/content/out4.mp4\"\n",
        "SEQUENCE_LENGTH=16"
      ],
      "metadata": {
        "id": "xBTOrf9Bk1Pd"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "print(Fight_utils.FightInference(video_file_path1,CLASSES_LIST,model_ft,device,SEQUENCE_LENGTH))\n",
        "print(Fight_utils.FightInference_Time(video_file_path1,CLASSES_LIST,model_ft,device,SEQUENCE_LENGTH))"
      ],
      "metadata": {
        "id": "QCECCd24mBrW",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "0f8fb8a5-4a14-42eb-fb0c-4a7670a0ac25"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "noFight\n",
            "[('noFight', 0.94467), ('fight', 0.05533)]\n",
            "***********\n",
            "time is: 0.9961555004119873\n",
            "noFight\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "print(Fight_utils.FightInference(video_file_path2,CLASSES_LIST,model_ft,device,SEQUENCE_LENGTH))\n",
        "print(Fight_utils.FightInference_Time(video_file_path2,CLASSES_LIST,model_ft,device,SEQUENCE_LENGTH))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "62vGYR8QTY90",
        "outputId": "ebc60729-e411-4a39-cb5f-a1d3833b76d0"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "fight\n",
            "[('fight', 1.0), ('noFight', 0.0)]\n",
            "***********\n",
            "time is: 1.4432260990142822\n",
            "fight\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "print(Fight_utils.FightInference(video_file_path3,CLASSES_LIST,model_ft,device,SEQUENCE_LENGTH))\n",
        "print(Fight_utils.FightInference_Time(video_file_path3,CLASSES_LIST,model_ft,device,SEQUENCE_LENGTH))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "bJ9qaiVHTZsm",
        "outputId": "9cda596b-6d30-4f86-efed-5d54aafa5bd3"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "fight\n",
            "[('fight', 1.0), ('noFight', 0.0)]\n",
            "***********\n",
            "time is: 1.2459924221038818\n",
            "fight\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "print(Fight_utils.FightInference(video_file_path4,CLASSES_LIST,model_ft,device,SEQUENCE_LENGTH))\n",
        "print(Fight_utils.FightInference_Time(video_file_path4,CLASSES_LIST,model_ft,device,SEQUENCE_LENGTH))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "ZMCQHlsHTaLJ",
        "outputId": "5d170c6e-8469-4148-90cb-a14c77cb2248"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "fight\n",
            "[('fight', 0.99943), ('noFight', 0.00057)]\n",
            "***********\n",
            "time is: 4.212649822235107\n",
            "fight\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "__________________________________________________________________________"
      ],
      "metadata": {
        "id": "DGsNx5k0nTqw"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Inference on Video Stream"
      ],
      "metadata": {
        "id": "lK-R0D4Cm7bx"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## noFight Video"
      ],
      "metadata": {
        "id": "2KoF3kU_QywL"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "start_time = time.time()\n",
        "outVideo_1=Fight_utils.showIference(1,CLASSES_LIST,model_ft,device,32,2)\n",
        "elapsed = time.time() - start_time\n",
        "print(\"time is:\",elapsed)"
      ],
      "metadata": {
        "id": "YtZgdF2jiGuL"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "VideoFileClip(outVideo_1, audio=False, target_resolution=(300,None)).ipython_display()"
      ],
      "metadata": {
        "id": "KOpQtXf7m-5a"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Fight Video"
      ],
      "metadata": {
        "id": "rRN1p6aMQ5wW"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "start_time = time.time()\n",
        "outVideo_2=Fight_utils.showIference(2,CLASSES_LIST,model_ft,device,16,2)\n",
        "elapsed = time.time() - start_time\n",
        "print(\"time is:\",elapsed)"
      ],
      "metadata": {
        "id": "4hs60zFwiKVt"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "VideoFileClip(outVideo_2, audio=False, target_resolution=(300,None)).ipython_display()"
      ],
      "metadata": {
        "id": "-VNggS-Covmy"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Video Contains Fight and noFight Video with `Seq 16`"
      ],
      "metadata": {
        "id": "vgTuwZ_HRKq6"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "start_time = time.time()\n",
        "outVideo_3=Fight_utils.showIference(3,CLASSES_LIST,model_ft,device,16,2)\n",
        "elapsed = time.time() - start_time\n",
        "print(\"time is:\",elapsed)"
      ],
      "metadata": {
        "id": "ZxAPUZAuiNIV"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Video Contains Fight and noFight Video with `Seq 16`"
      ],
      "metadata": {
        "id": "l6v0a-QwZvj6"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "start_time = time.time()\n",
        "outVideo_4=Fight_utils.showIference(4,CLASSES_LIST,model_ft,device,16,2)\n",
        "elapsed = time.time() - start_time\n",
        "print(\"time is:\",elapsed)"
      ],
      "metadata": {
        "id": "msONRuiEiR50"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "VideoFileClip(outVideo_4, audio=False, target_resolution=(300,None)).ipython_display()"
      ],
      "metadata": {
        "id": "zszwLuBsy2-2"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Save Videos to Drive"
      ],
      "metadata": {
        "id": "q3cOtrH5ToV1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Save Video to Drive\n",
        "!cp '/content/inferOut_1_16.mp4' \"/content/drive/MyDrive/Fight_Detection_Project/\"\n",
        "!cp '/content/inferOut_2_16.mp4' \"/content/drive/MyDrive/Fight_Detection_Project/\"\n",
        "!cp '/content/inferOut_3_16.mp4' \"/content/drive/MyDrive/Fight_Detection_Project/\"\n",
        "!cp '/content/inferOut_4_16.mp4' \"/content/drive/MyDrive/Fight_Detection_Project/\""
      ],
      "metadata": {
        "id": "yMse859uRReF"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "________________________________________________________________"
      ],
      "metadata": {
        "id": "Ig-CtZ8ICgp9"
      }
    }
  ]
}